Hi,
I am very new to .Net I want to connect to SQL Server display data on the web with the following code, but the problem is if I key in a Social Security Number which is not in the SYstem, error occur... what should i DO, thanks, thanks, thanks,
<%@ Page Language="VB" debug="true" ContentType="te xt/html" ResponseEncodin g="iso-8859-1" %>
<%@import namespace="syst em.data"%>
<%@import namespace="syst em.data.oledb"% >
<%@import namespace="syst em.data.sqlclie nt"%>
<script runat=server>
sub checklastname(S ource as Object,E as EventArgs)
Dim Conn as oledbconnection
Dim myadapter as OleDbDataAdapte r
dim mydataset as new dataset
conn=new oledbconnection ("Provider=SQLO LEDB;Data Source=datasour cename;Database =databasename;U ser ID=;Password=;" )
Conn.open()
myadapter=new OleDbDataAdapte r("Select lastname from testtable where ssn=123121234;" ,conn) ' Error occurs here... becasue 123121234 is not int 'the sysetm
myadapter.Fill( mydataset,"test ")
txtlastname.tex t=mydataset.tab les("test").row s(0).Item("last name")
conn.close()
end sub
I am very new to .Net I want to connect to SQL Server display data on the web with the following code, but the problem is if I key in a Social Security Number which is not in the SYstem, error occur... what should i DO, thanks, thanks, thanks,
<%@ Page Language="VB" debug="true" ContentType="te xt/html" ResponseEncodin g="iso-8859-1" %>
<%@import namespace="syst em.data"%>
<%@import namespace="syst em.data.oledb"% >
<%@import namespace="syst em.data.sqlclie nt"%>
<script runat=server>
sub checklastname(S ource as Object,E as EventArgs)
Dim Conn as oledbconnection
Dim myadapter as OleDbDataAdapte r
dim mydataset as new dataset
conn=new oledbconnection ("Provider=SQLO LEDB;Data Source=datasour cename;Database =databasename;U ser ID=;Password=;" )
Conn.open()
myadapter=new OleDbDataAdapte r("Select lastname from testtable where ssn=123121234;" ,conn) ' Error occurs here... becasue 123121234 is not int 'the sysetm
myadapter.Fill( mydataset,"test ")
txtlastname.tex t=mydataset.tab les("test").row s(0).Item("last name")
conn.close()
end sub
Comment