chris_rulez001 Posted July 22, 2008 Share Posted July 22, 2008 Hi, im making a project in visual basic, i am making a order form for items. all i want is to type the catologue number in 1 textbox and then it display the name of the item in another textbox. Code: Imports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox2.Enabled = False End Sub Private Sub CheckBox1_Checked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked Then TextBox2.Enabled = True End If End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim ConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../../../../../Shop.mdb;User Id=;Password=;" Dim oConn As New OleDbConnection(ConnStr) oConn.Open() Dim r1, r2 As OleDb.OleDbCommand r1 = New OleDb.OleDbCommand("SELECT Catologue Number FROM Stock WHERE Catologue Number = '" & TextBox1.Text & "'", oConn) r2 = New OleDb.OleDbCommand("SELECT Name FROM Stock WHERE Catologue Number = '" & TextBox1.Text & "'", oConn).ToString If r1.ExecuteScalar.ToString <> TextBox1.Text Then Else TextBox3.Text = r2.ExecuteScalar.ToString End If oConn.Close() End Sub End Class Error: "Syntax error (missing operator) in query expression 'Catologue Number'." can anyone help? im sooo confused ??? Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/ Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 This is an sql problem, nothing to do with vb.net. Field names should not contain spaces, however if you insist on using spaces I believe you can use [] brackets to enclose the field name (this only applies to access and other MS database types). eg; "SELECT [Catologue Number] FROM Stock WHERE [Catologue Number] = '" & TextBox1.Text & "'" Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/#findComment-596930 Share on other sites More sharing options...
chris_rulez001 Posted July 22, 2008 Author Share Posted July 22, 2008 This is an sql problem, nothing to do with vb.net. Field names should not contain spaces, however if you insist on using spaces I believe you can use [] brackets to enclose the field name (this only applies to access and other MS database types). eg; "SELECT [Catologue Number] FROM Stock WHERE [Catologue Number] = '" & TextBox1.Text & "'" thanks, but i now have an error: "Object reference not set to an instance of an object." Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/#findComment-596944 Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 Is that all the error you get? Not very helpfull is it? It is however a vbs error, I can tell you that mutch, behond that though, sorry, I dont' and wouldn't use vb. Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/#findComment-596951 Share on other sites More sharing options...
chris_rulez001 Posted July 22, 2008 Author Share Posted July 22, 2008 Is that all the error you get? Not very helpfull is it? It is however a vbs error, I can tell you that mutch, behond that though, sorry, I dont' and wouldn't use vb. ok ill look into it and see what i find, thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/#findComment-596955 Share on other sites More sharing options...
captbeagle Posted July 24, 2009 Share Posted July 24, 2009 Have you tried stepping through the debug execution one line at a time to see where the app is falling apart at? That may help substantially. Quote Link to comment https://forums.phpfreaks.com/topic/116086-visual-basic-net-help-please/#findComment-882312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.