| Author |
Topic |
|
associates
Starting Member
31 Posts |
Posted - 2006-09-01 : 03:44:41
|
| Hi,I was wondering how i could perform query say insert a new record if i use Visual Basic .NET as the front end and SQL Server 2000 as the backend. Thank you in advance. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-01 : 03:47:40
|
| INSERT INTO SomeTable (SomeCols...) VALUES (1, 2, 3...)orINSERT INTO SomeTable (SomeCols...) SELECT SomeCols FROM OtherTablePeter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-01 : 04:10:58
|
Peso, I think what he expects is front-end way to insert data (using may be datasets etc.) Here, is one way:Dim sqltext As StringDim cmdresults As Integersqltext = "Insert into Table(col1,col2) values(1,2)"OleDbCommand1.CommandType = CommandType.TextOleDbCommand1.CommandText = sqltextOleDbConnection1.Open()cmdresults = OleDbCommand1.ExecuteNonQuery()OleDbConnection1.Close() Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-01 : 04:31:15
|
| I assumed he had knowledge in vb.net and lacked knowledge in SQL.Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
associates
Starting Member
31 Posts |
Posted - 2006-09-06 : 04:17:16
|
| Thank you to you all for your help.Honestly, i have a better knowledge of SQL than VB studio .NET 2003. I was trying to learn it myself thru the online help but couldn't find the one that help me with for example, to populate a listbox with the records taken from the SQL Server. But if you know anything, i'm more than happy to heed it.Thanks a lot for your help |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-06 : 04:22:14
|
quote: Originally posted by associates Thank you to you all for your help.Honestly, i have a better knowledge of SQL than VB studio .NET 2003. I was trying to learn it myself thru the online help but couldn't find the one that help me with for example, to populate a listbox with the records taken from the SQL Server. But if you know anything, i'm more than happy to heed it.Thanks a lot for your help
Here is an example code for filling dropdown listbox, see whether it is of any help to you:[url]http://www.aspfree.com/c/a/ASP-Code/Populate-a-Dropdown-List-box-using-VBNET-and-Codebehind-page/[/url]Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
associates
Starting Member
31 Posts |
Posted - 2006-09-08 : 00:21:21
|
| Hi Harsh_athalyeThank you for your help.I hope this time, i'm not asking a big favor of you. What i've been doing is to try out some of the codes from the "101 VB.Net samples" zip file i downloaded from the internet. I'm trying out the project called "How to data entry sample". I notice that there is a ListItem object created there. My question is if you look at the frmMain.vb, there is a sub for PopulateProductList().Here is the code quotedobjListItem = New ListItem(drSQL.Item("ProductName").ToString(), _ CInt(drSQL.Item("ProductID"))lstProducts.Items.Add(objListItem)It appears to me that there should be two columns on the listbox, one shows the Product Name and the other is the ProductID. But why does it only show one columns that is ProductName in the listbox when running the project?What happens to the ProductID?Thank you in advance |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-08 : 03:48:49
|
Because you interpreted it wrongly.Actually, when you sayobjListItem = New ListItem(drSQL.Item("ProductName").ToString(), _CInt(drSQL.Item("ProductID"))you are not creating multi-column listbox...First argument is what you are going to display while second argument stands for the underlying value for that item. For e.g. you may want to show Emp names in list box, but on selection of name you may want to get its associated emp id for the query purpose. So in this case, you would code likeobjListItem = New ListItem(drSQL.Item("EmpName").ToString(), _CInt(drSQL.Item("EmpID"))Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
associates
Starting Member
31 Posts |
Posted - 2006-09-10 : 20:15:22
|
| Harsh_athalye,Thank you for your reply and your clear explanation.Yes, you're right that i misinterpreted it because i was desperate to want the listbox to show multicolumns but couldnot find a way to do it. I'm still learning my way around .NET. I learnt VB before but it's been a while i haven't touched it. So i was wondering if there is a way of displaying multicolumns listbox and also wonder if there are good VB .NET books around that explains well on the development of VB applications. Thank you in advance |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-10 : 20:35:33
|
| It is better to post .NET related questions at related forumMadhivananFailing to plan is Planning to fail |
 |
|
|
|