good eveninh sir/madam,

error is :- An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

code is : -

Dim a, b As Date
a = Date.Now.Date
b = a.Now.AddDays(-7)
Dim dataset2 As New DataSet

Dim myconn As SqlConnection = New _
SqlConnection("server=;database=project3;uid=;pwd=")


Dim obj_deletecommand As New SqlCommand
obj_deletecommand.Connection = myconn
obj_deletecommand.CommandText = "delete from dum_table"
myconn.Open()
obj_deletecommand.ExecuteNonQuery()
myconn.Close()
Dim str5 As String
str5 = "select t_candidates.reg_no,f_name,l_name,email_id,t_city.city,state,t_category.category,exprience from t_candidates join t_city on t_city.city_id=t_candidates.city_id join t_additionalinfo on t_candidates.reg_no=t_additionalinfo.reg_no join t_category on t_additionalinfo.cat_id=t_category.cat_id where (system_date)>='" & b & "' and (system_date)<='" & a & "'"

'str5 = "select t_candidates.reg_no,f_name,l_name,email_id,t_city.city,state,t_category.category,exprience from t_candidates join t_city on t_city.city_id=t_candidates.city_id join t_additionalinfo on t_candidates.reg_no=t_additionalinfo.reg_no join t_category on t_additionalinfo.cat_id=t_category.cat_id where day(system_date)='" & str4 & "' and month(system_date)='" & str6 & "' and year(system_date)='" & str7 & "'"

'----------------------------- DATA-BINDING FOR NEW RESUME
Try
Dim mydataadapter As SqlDataAdapter = New SqlDataAdapter(str5, myconn)
myconn.Open()
mydataadapter.Fill(dataset2, "t_candidates")
myconn.Close()

Catch exp As SqlException
MsgBox(exp.Message, MsgBoxStyle.Critical, "SQL error")
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, "General error")
End Try
Dim rowcount As Integer
rowcount = dataset2.Tables("t_candidates").Rows.Count

Dim i As Integer = 0
While (i <= rowcount - 1)

Dim reg_no As String
Dim f_name As String
Dim l_name As String
Dim email_id As String
Dim city As String
Dim state As String
Dim category As String
Dim exprience As String
reg_no = dataset2.Tables("t_candidates").Rows(i)(0)
f_name = dataset2.Tables("t_candidates").Rows(i)(1)
l_name = dataset2.Tables("t_candidates").Rows(i)(2)
email_id = dataset2.Tables("t_candidates").Rows(i)(3)
city = dataset2.Tables("t_candidates").Rows(i)(4)
state = dataset2.Tables("t_candidates").Rows(i)(5)
category = dataset2.Tables("t_candidates").Rows(i)(6)
exprience = dataset2.Tables("t_candidates").Rows(i)(7)
Dim objcommand As New SqlCommand
Try
objcommand.Connection = myconn
objcommand.CommandText = "insert into dum_table(reg_no,f_name,l_name,email_id,city,state,category,exprience)values('" & reg_no & "','" & f_name & "','" & l_name & "','" & email_id & "','" & city & "','" & state & "','" & category & "','" & exprience & "')"
Catch exp As SqlException
MsgBox(exp.Message, MsgBoxStyle.Critical, "SQL error")
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, "General error")
End Try

myconn.Open()
objcommand.ExecuteNonQuery()
myconn.Close()

i = i + 1
End While


Dim objcrystal As New frmcrystallastweek
objcrystal.Show()

End Sub

hello sir / madam,

i have return following function for accepting only characters
but it is not allowing me to take backspace key
pl tel me


Function alphabet(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
Dim keyascii As Integer
keyascii = Asc(e.KeyChar)
Select Case keyascii
Case Asc("A") To Asc("z")
e.Handled = False
Case Else
e.Handled = True
End Select
End Function

key char = 8 is backspace

Hi guys,

Following is my code-
-------------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strIP_Port As String
Dim strUID As String
Dim strPsw As String

strIP_Port = startup.txtIP.Text & "," & startup.txtPort.Text
strUID = startup.txtUName.Text
strPsw = startup.txtPsw.Text

oSQLConn.ConnectionString = _
"Network Library=DBMSSOCN;" & _
"Data Source=" & strIP_Port & ";" & _
"Initial Catalog=NMSDB;" & _
"User ID=" & strUID & ";" & _
"Password=" & strPsw
Try
oSQLConn.Open()
Catch ex As SqlException
MsgBox("Error" & ex.Message.ToString())
MsgBox("Error in Database Connection\nPlease check the Database parameters again")
Catch ex1 As Exception
MsgBox("Exception")
Finally
oSQLConn.Close()
oSQLConn.Dispose()
End

End Try

End Sub
--------------------------------------------------------------------------
Although the above code is quite straightforward, I am having trouble in the exception handling (I am doing this first time in VB.Net). Although I am providing some invalid parameters to the connection string, I am not able to see the msgbox in the application. The exception is cached but the catch block statements as well as finally block statements are not responding. instead it proceeds to the next modules.
I know, I must have done some silly mistake in the code. But still I am expecting your reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.