|
|
found out the problem with the code...i think.
when i click to add it to the database the msgbox comes up and basically says it cant find the path to the database... i don't know why, the database file is in the debug in the same project.
message:- 'could not find file 'U:\visual studio 2005\projects\manager login\manager login\bin\debug\PCBank'
Imports System.Data.OleDb
Public Class cust
Public conn As OleDbConnection
Public comm As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Dim icount As Integer
Dim str As String
Private Sub cust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection 'establishes that conn is a new connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PCBank.mdb" 'the name of the connection (name of the database on the end)
conn.Open() 'opens the connection
comm = New OleDbCommand 'establishes that comm is a new command
comm.Connection = conn 'the connection for the command is the connection specified
comm.CommandType = CommandType.Text 'the commands are in text
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=PCBank")
conn.Open()
comm = New OleDbCommand("insert into customers(CustomerID,CustomerSurname,CustomerForename) values('" & (tbID.Text) & "','" & (tbSur.Text) & "','" & (tbFor.Text) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
End Class
|
|
|
|
|
don't worry about it. finally managed to figure it out.
it was something so simple its stupid.
CustomerForename should of been CustomerForenames
PCBank needed .mdb at the end.
i feel like i've been wasting my entire life(or a couple of weeks)
thanks for all your help.
i'll probably be bugging you again soon
|
|
|
|
|
peteyshrew wrote: it was something so simple its stupid.
That happens alot in this business, even to the Pro's! :->
I noticed you're using the same connection string and just retyping it over and over when you need it, at least twice anyway. You might want to consider moving your database code to a seperate layer, or at least moving the connection code to a Shared (static in C#) method, like this:
Public Class SqlHelpers
Public Shared GetConnection(ByVal OleDbFileName As String) As OleDbConnection
' Your connection string goes here. Whether it's hard coded (bad idea!), or
' stored in the registry or in an app.config file, this method should
' retrieve it and create a new connection object out of it.
'
' This example will see if the specified database exists in the same path
' the .EXE was launched from, and if so, create a new OleDbConnection out of it.
Dim FullPath As String = Path.Combine(Application.StartupPath, OleDbFileName)
If File.Exists(FullPath) Then
Dim connString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", FullPath)
Return New OleDbConnection(connString)
Else
Throw New FileNotFoundException("Unable to find the database file " & _
OleDbFileName & " in the application startup path!")
End If
End Sub
.
. other helper methods...
.
End Class
When you want to get a new connection to the database, just do this:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
Dim conn As OleDbConnection = SqlHelpers.GetConnection("PCBank.mdb")
Dim comm As New OleDbCommand("insert into customers CustomerID, CustomerSurname, CustomerForename) " & _
"values('" & (tbID.Text) & "','" & (tbSur.Text) & "','" & (tbFor.Text) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Not IsNothing(conn) AndAlso conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Try
End Sub
This is nowhere near the "perfect" implementation, but it gives you an idea of what should be going on.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
The way I work with connection strings is I store them in the app.config file then I have a function to retrieve it like this:
Public Shared Function GetConnectionString(ByVal strConnection As String) As String
Dim strReturn As New String("")
If Not String.IsNullOrEmpty(strConnection) Then
strReturn = ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
Else
strReturn = ConfigurationManager.ConnectionStrings("YourConnectionStringName").ConnectionString
End If
Return strReturn
End Function
I do it this way that way I can have multiple connection strings and just pass the name of the connection string, otherwise it defaults to the default connection.
SELECT * FROM Users WHERE Clue > 0
ERROR: 0 Rows Returned
|
|
|
|
|
dude try to put your database in the folder "BIN" of your project. i encounter that problem too and i fix it when i put my database in the folder "BIN" of my project. if the error still prompt, post it again.
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|
I have an application in Asp.net.In my machine sql server2000 and 2005 instaled.
I want to connect my project with sql server 2005.Suppose DB name is BBN,but problem is that this DB name is also exist in sql server2000.Now Plz tell me how can i connect my project with sql server2005.
Thanks in advance......
Sujit
|
|
|
|
|
YOu just need to know the name of the sql server. If you have both installed on a single box most likely one of them is an instance. So if you open up sql manager and open a connection to the sql 2005 box what ever name you use to open the connection is what you should use in your connection string in asp.net.
Hope that helps.
Ben
|
|
|
|
|
<appsettings>
<add key="forumDSN" value="server=sujit;uid=sa;pwd=sa;database=BBN">
this is my connection string.but my project by default connect to the sql server2000 not with the sql server2005.
Sujit
|
|
|
|
|
You need to check the little box call "Ignore HTML tags in this message" when you post code that has things like < or > in it.
Please re-post your connection string.
Ben
|
|
|
|
|
add key="forumDSN" value="server=sujit;uid=sa;pwd=sa;database=BBN"
this is my connection string.
Sujit
|
|
|
|
|
So if that is your current sql 2000 sever I would guess your 2005 server connection string would be something like:
add key="forumDSN" value="server=sujit\instance;uid=sa;pwd=sa;database=BBN"
Where the \instance is your 2005 sql server name.
By the way it is usually a bad idea to have your sa password be sa.
Ben
|
|
|
|
|
first of all thanks for help..
i have a small question..
from where i can get the sql server name???
Sujit
|
|
|
|
|
Ok kubben..Thanks for help.I hv got my answer.
Sujit
|
|
|
|
|
Hi,
i would like to know how to get infiniti symbol by using ASCII code? what is the number?
i check from msdn ASCII Character Codes Chart 2
http://msdn2.microsoft.com/en-us/library/9hxt0028(VS.71).aspx[^]
the dec number is 236. i has code it as chr(236). but i can't this symbol.
Is there anyone know how can i get it ?
Thanks in advance
Regards,
merlyn
|
|
|
|
|
The ASCII code is correct. The reason you cannot see the character is most likely that the font you are using does not support that character
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
I see, Thanks!
But is there any way we can know which font support for that character ?
|
|
|
|
|
The only way to know is to look at it in Character Map. On XP, open Program, Accessories, System Tools, Character Map. At the bottom of the window, enable the Avanced View. You'll get a little search box. Just type "Infinity" in there (without the quotes) and it'll show you if whatever font you pick at the top of the box supports the character and what it's number is. If a font supports it, it's usually going to be the same number, but not always. In Courier New, it's Unicode character 221E.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
ok, got it.
thanks
|
|
|
|
|
this is my first time to use SQLServer 2005 Express and i have a problem creating a database. I can't find Enterprice Manager in SQLServer 2005 Express like what SQLServer 2003 have. Any one can guide me how to create database in SQLServer 2005 Express.Thx in advance
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
This is a question for the SQL message board, surely, but Enterprise Manager is now called SQL Server Management Studio Express and can be downloaded from the Microsoft website
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
oh i see. thx 4 the info.
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|
Hi in my project default page i am using frame set in that 3 html pages i included...,
When run the project it will check login authentication..,
If its correct user...,then in that default page head htmlpage my link buttons will display...,
When i click in that link left side html page sub links will be display...,
if i click any of the sub link then my aspx page will be display in that 3rd html page(right hand side)...,
In this i said suppose the user didnt interact with some what time the forms then session will be end...,so it will transfer to login.aspx page...,
But the login.aspx page is displaying on the right hand side of the frameset..,
But when session will end i need only starting page login.aspx other head html page and left side html page all want to unload
How to do this one plz tell me...,
-- modified at 2:00 Thursday 19th April, 2007
Magi
|
|
|
|
|
Not sure if I'm understanding you correctly but my take on it is this - dump the frames idea and use html tables for positioning instead. Frames are a pain & a mission to work with.
If you're using .NET 2.0 make use of a master page and place the ContentHolder control where you currently have your 3rd page frame. Using a master page you could also create your navigation menus to behave as you described above and only have to create it once. Unless you can write some nifty JavaScript it may involve a postback to populate your list of sub links.
|
|
|
|
|
I want to mix two audio files in any of the .mp3 or .wav formats and generate a new one . can any boday help me in finding the solution.
|
|
|
|