|
-
Aug 29th, 2011, 03:47 AM
#1
Thread Starter
Lively Member
SELECT * Not Working For Access Database
for the first time i am havin this kind of issue, i tried some google'in but of none help.
Code:
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Log("Application Started Successfully")
Log("Attempting To Connect To Database", True)
If dbConnect(Application.StartupPath & "\myDatabase.mdb") Then
Log("Successfully Connected To Database", True)
Else
MessageBox.Show("Unable To Connect To Database Critical Error", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
'Using cmd As New OleDb.OleDbCommand("INSERT INTO MY_SETTING VALUES(1, 'TEST', 'TEST')", Conn)
' Debug.Print("Record's Affected : " & cmd.ExecuteNonQuery())
'End Using
Using cmd As New OleDbCommand("SELECT * from MY_SETTING;", Conn)
Debug.Print("Total ID : " & cmd.ExecuteNonQuery())
End Using
End Sub

The weird problem is INSERT is working but Select is not working!
Last edited by -RaJ-; Aug 29th, 2011 at 03:59 AM.
-
Aug 29th, 2011, 03:52 AM
#2
Re: SELECT * Not Working For Access Database
Please try posting your code again. Also, please explain what "not working" actually means.
-
Aug 29th, 2011, 03:58 AM
#3
Thread Starter
Lively Member
Re: SELECT * Not Working For Access Database
ty, i have posted again, the only problem is "SELECT" is not working at all!
here is image my my database
-
Aug 29th, 2011, 05:27 AM
#4
Thread Starter
Lively Member
Re: SELECT * Not Working For Access Database
-
Aug 29th, 2011, 05:52 AM
#5
Thread Starter
Lively Member
Re: SELECT * Not Working For Access Database
i even tried with sqlcompactce, and its the same
INSERT WORKING but SELECT is not working!
-
Aug 29th, 2011, 06:55 AM
#6
Re: SELECT * Not Working For Access Database
what do you meant by "it's not working" ??? Did you get toast when you asked for OJ? Did your door suddenly fall off the hinges? Did the tires fall off your car? Or did your arms fall off? We are not mind readers. People seem to think we are for some reason... I don't know why... but it's a rumour that's been around for almost as long as I can remember. Not quite sure what you're expecting to happen... perhaps if you removed the eels from your hover craft...
-tg
-
Aug 29th, 2011, 08:15 AM
#7
Thread Starter
Lively Member
Re: SELECT * Not Working For Access Database
by not working i meant to say is its showing 0 record's affected for that query command
Code:
Using cmd As New OleDbCommand("SELECT * from MY_SETTING;", Conn)
Debug.Print("Total ID : " & cmd.ExecuteNonQuery())
End Using
it must show some positive non zero values, in other word's its not able to select it !! to data reader
DataReader is showing as
.hasRow = False
this error has never happened to me before!
-
Aug 29th, 2011, 08:30 AM
#8
Re: SELECT * Not Working For Access Database
That's because you're using the ExecuteNonQuery ... there were NO ROWS affected... you didn't CHANGE any rows... so yeah, that's what I would expect. Your datareader is showing no rows because you used the ExecuteNonQuery... and not the ExecuteReader...
ExecuteNonQuery Documentation:
http://msdn.microsoft.com/en-us/libr...enonquery.aspx
ExecuteReader Documentation:
http://msdn.microsoft.com/en-us/libr...utereader.aspx
Might want to brush up on what each one does...
-tg
-
Aug 29th, 2011, 08:36 AM
#9
Re: SELECT * Not Working For Access Database
 Originally Posted by -RaJ-
by not working i meant to say is its showing 0 record's affected for that query command
Code:
Using cmd As New OleDbCommand("SELECT * from MY_SETTING;", Conn)
Debug.Print("Total ID : " & cmd.ExecuteNonQuery())
End Using
it must show some positive non zero values, in other word's its not able to select it !! to data reader
DataReader is showing as
.hasRow = False
this error has never happened to me before!
What is confusing is, do you want to return rows or a count of rows?
Seeing this yet at the same time Total mixed with ID does not makes sense
Code:
Debug.Print("Total ID : " & cmd.ExecuteNonQuery())
Looks like you want total row count which would be done as follows.
Code:
cmd.CommandText = "SELECT COUNT(*) From MY_SETTING"
Dim CustCount = CLng(cmd.ExecuteScalar)
If you want rows back and not a count then use cmd.ExecuteReader.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|