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