작은 전화 번호부 응용 프로그램을 만들고 전 필드가 FullName, Job, Phone1, Phone2, Notes 및 SN primary 인 전화라는 테이블의 액세스 데이터베이스에 전화를 저장하고 있습니다. 키.액세스로 받아 들인 입력에 대해 oledbexception이 발생했습니다.
fullname 및 phone1을 필수로 설정하고 fullname에 대한 유효성 검사 규칙을 Len([FullName])>3
으로 설정하고 phone1 및 phone2에 대한 유효성 검사 규칙을 Like "[0-9]*"
으로 설정하고 유효성 검사 규칙에 대한 유효성 검사 메시지도 설정합니다.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="253" Width="685">
<Grid Height="206" Width="658">
<Label Content="FullName" Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Label1" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="78,16,0,0" Name="FullName" VerticalAlignment="Top" Width="185" />
<Label Content="Job" Height="28" HorizontalAlignment="Left" Margin="29,46,0,0" Name="Label2" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="78,46,0,0" Name="Job" VerticalAlignment="Top" Width="185" />
<Label Content="Phone1" Height="28" HorizontalAlignment="Left" Margin="22,75,0,0" Name="Label3" VerticalAlignment="Top" />
<Label Content="Phone2" Height="28" HorizontalAlignment="Left" Margin="269,16,0,0" Name="Label4" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="78,75,0,0" Name="Phone1" VerticalAlignment="Top" Width="110" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="325,21,0,0" Name="Phone2" VerticalAlignment="Top" Width="110" />
<Label Content="Notes" Height="28" HorizontalAlignment="Left" Margin="274,56,0,0" Name="Label5" VerticalAlignment="Top" />
<TextBox Height="95" HorizontalAlignment="Left" Margin="325,60,0,0" Name="Notes" VerticalAlignment="Top" Width="328" AcceptsReturn="True" AcceptsTab="True" />
<Button Content="Save" Height="37" HorizontalAlignment="Left" Margin="274,161,0,0" Name="Button2" VerticalAlignment="Top" Width="135" />
</Grid>
이 저장 핸들러를 클릭합니다 : 나는 데이터 집합 및 TableAdapter가 코드를 생성하는 비주얼 스튜디오를 사용하여 액세스 데이터베이스를 추가 한 WPF 응용 프로그램에서
,이 MainWindow.xaml입니다private button2_Click(object sender , RoutedEventArgs e)
{
try
{
PhonesDataSetPhonesTableAdapter.Insert(FullName.Text, Job.Text, Phone1.Text, Phone2.Text, Notes.Text);
} catch(OleDbException ex) {
MessageBox.Show(ex.Message);
}
}
PhonesDataSetPhonesTableAdapter
는 다음과 같이 정의된다 :
나는 응용 프로그램을 실행하고 만 포함해야 OleDbException가
전화 번호가 문자가 포함되어 있습니다 PHONE1에 대한 확인 메시지가 발생합니다 PHONE1 번호로 전체 이름으로
John
및 작업으로programmer
및2137976
을 넣었을 때 숫자
하지만 어떤 문자도 포함되어 있지 않으며 액세스를 통해 동일한 입력을 시도 할 때 받아들입니다. 여기서 무슨 일이 벌어지고 있습니까? 어떻게 작동 시키나요?
참고 : 여기에
이 문제에 대한 몇 가지 배경입니다. 다른 모든 문자는 문자 일 수 있습니다. –