EDN Admin
Well-known member
<div style="color:Black;background-color:White; <pre>
<span style="color:Green; the insert sub
<span style="color:Blue; Sub Insert_str2_B(<span style="color:Blue; ByVal sql_Insert1 <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal sql_Insert2 <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal dbName <span style="color:Blue; As <span style="color:Blue; String)
<span style="color:Blue; Dim Conn_web <span style="color:Blue; As SqlConnection
Conn_web = MyFormz.connec.ConnWeb2(dbName)
Conn_web.Open()
<span style="color:Blue; Dim sqlcmd_Insert <span style="color:Blue; As <span style="color:Blue; New SqlCommand(sql_Insert1 + sql_Insert2, Conn_web)
<span style="color:Blue; Try
sqlcmd_Insert.ExecuteNonQuery()
MsgBox(<span style="color:#A31515; "The New Record has been saved.")
<span style="color:Blue; Catch ex <span style="color:Blue; As Exception
MsgBox(ex.Message)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
insert without stored procedure
<span style="color:Blue; Sub Insert_New_Converts_Followups(<span style="color:Blue; ByVal strFollowup_No <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_Date <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_By <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_Response <span style="color:Blue; As <span style="color:Blue; String)
<span style="color:Blue; Dim sql_Insert1 <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "INSERT INTO New_Converts_Followups(VisitorID, Followup_No, Followup_Date, Followup_By, Followup_Response )"
<span style="color:Blue; Dim sql_Insert2 <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "VALUES (" & <span style="color:Blue; Me.txtNew_ConvertsID.Text & <span style="color:#A31515; ", " & strFollowup_No & <span style="color:#A31515; ", " & strFollowup_Date & <span style="color:#A31515; ", " & strFollowup_By & <span style="color:#A31515; ", " & strFollowup_Response & <span style="color:#A31515; ")"
MyFormz.cl_Class.Insert_str2_B(sql_Insert1, sql_Insert2, txtDBname.Text)
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Green; insert code with stored procedure
<span style="color:Blue; Dim parm1 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Category_ID", <span style="color:#A31515; "")
<span style="color:Blue; Dim parm2 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Category", <span style="color:#A31515; "Value1")
<span style="color:Blue; Dim parm3 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Area_Name", <span style="color:#A31515; "Value2")
<span style="color:Blue; Dim cmd <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlCommand
cmd.CommandText = <span style="color:#A31515; "dbo.udp_tblArea_ups"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddRange(<span style="color:Blue; New SqlClient.SqlParameter() {parm1, parm2, parm3})
<span style="color:Blue; Dim cn <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlConnection(<span style="color:#A31515; "Data Source=*****;Initial Catalog=******;User ID=*****;Password=*****")
cn.Open()
cmd.Connection = cn
cmd.ExecuteNonQuery()
cn.Close()
[/code]
i used this code to do my insert but now that i have introduced stored procedures i have used the last code to do my inserts now iam stuck trying to retrieve the data i just inserted. any help will be greatly appreciated can anyone provide me with ideas of
how to adjust the procedure i have so that it can accomodate stored procedures(the insert procedure(sub))<hr class="sig If you think it you can achieve it
View the full article
<span style="color:Green; the insert sub
<span style="color:Blue; Sub Insert_str2_B(<span style="color:Blue; ByVal sql_Insert1 <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal sql_Insert2 <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal dbName <span style="color:Blue; As <span style="color:Blue; String)
<span style="color:Blue; Dim Conn_web <span style="color:Blue; As SqlConnection
Conn_web = MyFormz.connec.ConnWeb2(dbName)
Conn_web.Open()
<span style="color:Blue; Dim sqlcmd_Insert <span style="color:Blue; As <span style="color:Blue; New SqlCommand(sql_Insert1 + sql_Insert2, Conn_web)
<span style="color:Blue; Try
sqlcmd_Insert.ExecuteNonQuery()
MsgBox(<span style="color:#A31515; "The New Record has been saved.")
<span style="color:Blue; Catch ex <span style="color:Blue; As Exception
MsgBox(ex.Message)
<span style="color:Blue; End <span style="color:Blue; Try
<span style="color:Blue; End <span style="color:Blue; Sub
insert without stored procedure
<span style="color:Blue; Sub Insert_New_Converts_Followups(<span style="color:Blue; ByVal strFollowup_No <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_Date <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_By <span style="color:Blue; As <span style="color:Blue; String, <span style="color:Blue; ByVal strFollowup_Response <span style="color:Blue; As <span style="color:Blue; String)
<span style="color:Blue; Dim sql_Insert1 <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "INSERT INTO New_Converts_Followups(VisitorID, Followup_No, Followup_Date, Followup_By, Followup_Response )"
<span style="color:Blue; Dim sql_Insert2 <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "VALUES (" & <span style="color:Blue; Me.txtNew_ConvertsID.Text & <span style="color:#A31515; ", " & strFollowup_No & <span style="color:#A31515; ", " & strFollowup_Date & <span style="color:#A31515; ", " & strFollowup_By & <span style="color:#A31515; ", " & strFollowup_Response & <span style="color:#A31515; ")"
MyFormz.cl_Class.Insert_str2_B(sql_Insert1, sql_Insert2, txtDBname.Text)
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Green; insert code with stored procedure
<span style="color:Blue; Dim parm1 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Category_ID", <span style="color:#A31515; "")
<span style="color:Blue; Dim parm2 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Category", <span style="color:#A31515; "Value1")
<span style="color:Blue; Dim parm3 <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlParameter(<span style="color:#A31515; "@Area_Name", <span style="color:#A31515; "Value2")
<span style="color:Blue; Dim cmd <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlCommand
cmd.CommandText = <span style="color:#A31515; "dbo.udp_tblArea_ups"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddRange(<span style="color:Blue; New SqlClient.SqlParameter() {parm1, parm2, parm3})
<span style="color:Blue; Dim cn <span style="color:Blue; As <span style="color:Blue; New SqlClient.SqlConnection(<span style="color:#A31515; "Data Source=*****;Initial Catalog=******;User ID=*****;Password=*****")
cn.Open()
cmd.Connection = cn
cmd.ExecuteNonQuery()
cn.Close()
[/code]
i used this code to do my insert but now that i have introduced stored procedures i have used the last code to do my inserts now iam stuck trying to retrieve the data i just inserted. any help will be greatly appreciated can anyone provide me with ideas of
how to adjust the procedure i have so that it can accomodate stored procedures(the insert procedure(sub))<hr class="sig If you think it you can achieve it
View the full article