|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Code for stored proceduresI have been trying to find sample code for inserting into Sql Server 2000. I haven't been very successful. One thing I don't understand from the few snippets I've seen is how to connect the value in the textbox to the parameter. In .Net I would write the following: <snip> cmd.Parameters.Add("@TUserID", Session("UserID")) cmd.Parameters.Add("@TListType", 4) cmd.Parameters.Add("@TFirstName", txtFirstName.Text) cmd.Parameters.Add("@TLastName", txtLastName.Text) <snip> where it is obvious that the parameter value is coming from the textboxes. How and where do I put that into VB6? I have the following code sample from VB6: Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, FName) oCmd.Parameters.Append oPrm Set oPrm = oCmd.CreateParameter("@mi", adVarChar, adParamInput, 4, MI) oCmd.Parameters.Append oPrm Set oPrm = oCmd.CreateParameter("@lname", adVarChar, adParamInput, 20, LName) How and where would I connect the value from textboxes? I just plain don't get it. I think .Net is much easier, but unfortunately, I can't talk the powers that be into using it instead of VB6. Any help will be greatly appreciated! -- Sandy Sandy,
> Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, In the above line, you are passing whatever value is in the variable FName > FName) as the value of the parameter. It's a simple as that. So to pass the value that's in a TextBox called TextBox1, you would do: Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, TextBox1.Text) OR: FName = TextBox1.Text Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, FName) Note that using CreateParameter, the Value argument is optional. It simply allows you to specify a value for the Parameter you are creating at the time, rather than having to specify it later, as in: Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15) oPrm.Value = TextBox1.Text I don't use .Net, but it seems to me that the .Net syntax is actually very similar to VB6 (which is not surprising.) Cheers, Robert Show quoteHide quote "Sandy" <Sa***@discussions.microsoft.com> wrote in message news:1B57FDE6-7EEF-4666-9001-3999FFBFDE59@microsoft.com... > Hello - > > I have been trying to find sample code for inserting into Sql Server 2000. > I haven't been very successful. One thing I don't understand from the few > snippets I've seen is how to connect the value in the textbox to the > parameter. > > In .Net I would write the following: > > <snip> > cmd.Parameters.Add("@TUserID", Session("UserID")) > cmd.Parameters.Add("@TListType", 4) > cmd.Parameters.Add("@TFirstName", txtFirstName.Text) > cmd.Parameters.Add("@TLastName", txtLastName.Text) > <snip> > > where it is obvious that the parameter value is coming from the textboxes. > How and where do I put that into VB6? > > I have the following code sample from VB6: > > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, > FName) > oCmd.Parameters.Append oPrm > Set oPrm = oCmd.CreateParameter("@mi", adVarChar, adParamInput, 4, MI) > oCmd.Parameters.Append oPrm > Set oPrm = oCmd.CreateParameter("@lname", adVarChar, adParamInput, 20, > LName) > > How and where would I connect the value from textboxes? I just plain > don't > get it. I think .Net is much easier, but unfortunately, I can't talk the > powers that be into using it instead of VB6. > > Any help will be greatly appreciated! > > -- > Sandy Thanks, Robert!
-- Show quoteHide quoteSandy "Robert Ellis" wrote: > Sandy, > > > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, > > FName) > > In the above line, you are passing whatever value is in the variable FName > as the value of the parameter. It's a simple as that. > So to pass the value that's in a TextBox called TextBox1, you would do: > > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, > TextBox1.Text) > > OR: > > FName = TextBox1.Text > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, > FName) > > Note that using CreateParameter, the Value argument is optional. It simply > allows you to specify a value for the Parameter you are creating at the > time, rather than having to specify it later, as in: > > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15) > oPrm.Value = TextBox1.Text > > I don't use .Net, but it seems to me that the .Net syntax is actually very > similar to VB6 (which is not surprising.) > > Cheers, > > Robert > > > > > > > "Sandy" <Sa***@discussions.microsoft.com> wrote in message > news:1B57FDE6-7EEF-4666-9001-3999FFBFDE59@microsoft.com... > > Hello - > > > > I have been trying to find sample code for inserting into Sql Server 2000. > > I haven't been very successful. One thing I don't understand from the few > > snippets I've seen is how to connect the value in the textbox to the > > parameter. > > > > In .Net I would write the following: > > > > <snip> > > cmd.Parameters.Add("@TUserID", Session("UserID")) > > cmd.Parameters.Add("@TListType", 4) > > cmd.Parameters.Add("@TFirstName", txtFirstName.Text) > > cmd.Parameters.Add("@TLastName", txtLastName.Text) > > <snip> > > > > where it is obvious that the parameter value is coming from the textboxes. > > How and where do I put that into VB6? > > > > I have the following code sample from VB6: > > > > Set oPrm = oCmd.CreateParameter("@fname", adVarChar, adParamInput, 15, > > FName) > > oCmd.Parameters.Append oPrm > > Set oPrm = oCmd.CreateParameter("@mi", adVarChar, adParamInput, 4, MI) > > oCmd.Parameters.Append oPrm > > Set oPrm = oCmd.CreateParameter("@lname", adVarChar, adParamInput, 20, > > LName) > > > > How and where would I connect the value from textboxes? I just plain > > don't > > get it. I think .Net is much easier, but unfortunately, I can't talk the > > powers that be into using it instead of VB6. > > > > Any help will be greatly appreciated! > > > > -- > > Sandy > > >
how to convert string to date?
problem formatting excel in vb Text to Speech VB6 writing to text files requires Close to commit delete tmp files Using VB to screen scrape a 3270 mainframe Call a DLL in C from VB Error to create a package in VB6 Close a form object variable or with block variable not set error |
|||||||||||||||||||||||