|
Where do you intialize myCommand? Of course it will give a null reference exception if you haven't done so before attempting to use it.
only two letters away from being an asset
|
|
|
|
|
I have initialized myCommand but now I'm having other error messages. Would you please look at the code to see if the logic is it self the problem. Basically what I'm trying to do is validate the username before sending it to the database for storage. The code checks to see whether the username is already in existence or not. If it is then an error message is given, if not the username is sent to the database. Would you please look at the code to see if it even make logical sense. The code may not reflect what I want. Thanks for your help.
-- modified at 1:06 Friday 15th June, 2007
|
|
|
|
|
What are that other error messages and at which line?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
You are not initilizing the object of OdbcCommand class,
Before calling ExecuteScalar function ,right this statement,
myCommand=new OdbcCommand(strsql,myConnection)
Always remember,object reference not set to instance of object is exception throws whenever u r trying to use an object which is not initialized.
Send me reply if ut problem gets solved.
GIRISH
|
|
|
|
|
I think there is error in ur insert query,
it is Insert into table_name(columns) <b>values</b>
u have written value,this might be the proble.
If that doesnt wotks try the code given below,
Still if it is not working send me reply.
Private Sub lblRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblRegister.Click
Dim bResult As Boolean = False
Dim myConnection As OdbcConnection
Dim myCommand As OdbcCommand
Dim strInsert As String
Dim strGoodPassword As String
Dim strSQL As String
strSQL = String.Empty
myConnection = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDb;User=myUSERassword=myPW;Option=3;")
strSQL = String.Format("SELECT myUserName FROM myTable WHERE (email='{0}');", txtUserName.text)
myCommand =new OdbcCommand("SELECT myUserName FROM myTable WHERE email='" & txtUserName.text &"'")
myConnection.Open()
strGoodPassword = CType(myCommand.ExecuteScalar, String)
If Not strGoodPassword Is Nothing Then
If strGoodPassword = txtUserName.Text Then
bResult = True
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
Else
lblMessage.Text = "That user name is already taken!"
lblMessage.Text &= " Please choose another user name."
End If
strInsert = "INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode)value (?,?,?,?,?,?,?,?,?,?)"
myCommand As New OdbcCommand("INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode) values ('" & txtFirst.Text & "','" & txtLast.Text & "','" & txtPassword.Text & "','" & txtPhone.Text & "','" & txtEmail.Text & "','" & txtProfession.Text & "','" & txtAddress.Text & "','" & txtCity.Text & "','" & txtState.Text & "','" & txtZipCode.Text & "')",myConnection)
myConnection.Close()
End Sub
GIRISH
|
|
|
|
|
Thanks for responding to my post, however, your code has a few problems in it. VS2003 gave four error messages on the the following line.
myCommand As New OdbcCommand("INSERT into membersinfotbl (FirstName,LastName,Password,Phone,Email,Profession,StrAddress,City,State,ZipCode) values ('" & txtFirst.Text & "','" & txtLast.Text & "','" & txtPassword.Text & "','" & txtPhone.Text & "','" & txtEmail.Text & "','" & txtProfession.Text & "','" & txtAddress.Text & "','" & txtCity.Text & "','" & txtState.Text & "','" & txtZipCode.Text & "')",myConnection)
The messages are "Expression is not a method"
"Expression expected"
"Method arguments must be enclosed in parentheses"
"End of statement expected"
|
|
|
|
|
|
Don't use "Urgent Help Needed" in the subject. It is poor etiquette here and your question will be ignored by those who can help the most
only two letters away from being an asset
|
|
|
|
|
ASP is different to ASP.NET, you need to say ASP.NET.
If you get the data from Access, it should come back in a DataSet or Data Table. Just make that the data source of a grid, call it's DataBind method, and you're done. You can format it, and change how it looks, but that's all there is to displaying it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I recommend you take some time off this project to work through a book on ADO.NET, and possible a book on your chosen language.
A dataset is returned from Access. By definition, it is an object within the language, there is no extension or folder, nothing is stored in the project directory.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Could you please send me code how to send an email in ASP.Net 2.0
seema
|
|
|
|
|
Type "send mail asp.net" in to the search box above and click Go!
only two letters away from being an asset
|
|
|
|
|
using System.Net.Mail;
SmtpClient c = new SmtpClient("host");
MailMessage message = new MailMessage("from@email.com","to@mail.com","test","body");
c.Send(message);
|
|
|
|
|
Hi,
Problem: I have a web application that is tied into a Windows Workflow that tracks orders. In the portion of the application that allows the user to set/reset the state of an order I have a gridview and a formview. The gridview displays the meat of the order data as stored in the database, and the formview is where I'd like to store the buttons that will perform the updates and progress the order states.....etc.
I'd like to set the visibility of the different buttons in the formview dependant on the current state of the Workflow. I can get the current state of the order no problem from the gridview's OnItemCreated event.
I've tried to access the FormView control via: FormView fv = this.Page.FindControl("fvOrderState") as FormView; but hitherto I am unable to get any reaction from the FormView.
I would appreciate any and all suggestions and/or leads for this problem.
Thank you.
An American football fan -
Go Seahawks!
Lil Turtle
|
|
|
|
|
In my Web form I have DataGrid1 and want to
add 2 cols in DataGrid1.DataKeyField property.
If I had 1 col. it would be DataGrid1.DataKeyField = "ColName1",
but how can I add another more "ColName2"?
|
|
|
|
|
Hi,
If you r working on asp.net 2.0 then to get this facility you should use GridView Control.
Gridview has property called "DataKeyNames" which you can set to comma separated column names and you can access their values as following.
gv.DataKeys[keindex].Values[columnindex].ToString()
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
hi i'm trying to format TemplateColumn in datagrig wich is generated in codebehind file
the problem that TemplateColumn type hasn't DataFormatString property.
can you tel me how settings format in codebehind for a TemplateColumn
Thanks in advance!!!
|
|
|
|
|
In essence the Template is just a class that knows how to do dynamically
add other controls. So you'd have to write that class. Here'a a Microsoft
example:
Clickety[^]
Regards,
Satips.
|
|
|
|
|
My boss wanted me to make a data entry form so Jane can type customers' email addresses into our database. It needs to have two fields: store number and email address, and a submit button that inserts into the mailling list. ON my resume, i didn't put that I knew SQL....but yet I am still being asked to do this, can any one help me?
|
|
|
|
|
Just Create one form where you will collect the Store Number and Email and store it in the Database and then use the SMTP to send it to all of the Emails.
Regards,
Satips.
|
|
|
|
|
oh, ok thanks that helps with that part,
how do i attach or make the submit save the information on the forms work? or be stored?
|
|
|
|
|
Just drag and Drop one Button Control and just Double click that button and on the button_click write the code for storing it in the database.
Regards,
Satips.
|
|
|
|
|
I dont think I can do that Using Dreamweaver. :/
|
|
|
|
|
That is entirely Different.
You can simply do with the Asp.net Control itself.
Regards,
Satips.
|
|
|
|
|
ok i set up the page http://webice.net/addresses/addresses.asp BUT getting it to work with the MS access file, i don't know how to do that.
|
|
|
|
|