473,503 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database VB.Net problem

Private Sub writeDatabase(ByVal filePath As String, ByVal action As
String)
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim sqlStr As String
Dim connStr As String
connStr = "User ID=user;Password=user;Initial Catalog=file;" _
& "Data Source=(database.server.com)"
sqlStr = "insert into folderWatch values('filePath', 'action')"
cnn = New SqlConnection(connStr)
cnn.Open()
cmd = New SqlCommand(sqlStr, cnn)
cmd.ExecuteNonQuery()
cmd.Dispose()
cnn.Close()
End Sub
I am having problem with this code. I get unhandled execption when
cmd.executeNonQuery() is executed. I am not sure what I am doing
wrong.

Thanks,
irfan

Nov 21 '05 #1
7 1521
On 2005-08-28, humbleFunGuy <im**********@hotmail.com> wrote:
Private Sub writeDatabase(ByVal filePath As String, ByVal action As
String)
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim sqlStr As String
Dim connStr As String
connStr = "User ID=user;Password=user;Initial Catalog=file;" _
& "Data Source=(database.server.com)"


That's just "Data Source=database.server.com".

"(local)" is a special keyword recognized by the sql server driver.
Except when connecting to a local db, you don't want parentheses around
the data source.
Nov 21 '05 #2
humple,

Try to see your exception, I changed your code a little bit, and deleted as
well a lot what was a little bit unneeded. I did it in this message so watch
typos.

\\\
Private Sub writeDatabase(ByVal filePath As String, ByVal action As
String)
Dim cnn As SqlConnection("User ID=user;Password=user;" & _
"Initial Catalog=file;" & _
"Data Source=(database.server.com))"
dim sqlStr as string = "insert into folderWatch values('filePath',
'action')"
dim cmd as New SqlCommand(sqlStr, cnn)
Try
cnn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex as exception
messagebox.show("Query error: " & ex.tostring)
'this has to be a better procedure to handle by instance concurrency
End try
Catch ex as exception
messagebox.show("Connection error: " & ex.tostring)
Finally
cnn.Close()
End Try
End Sub
////

I hope this helps,

Cor
Nov 21 '05 #3
Cor,
I tried to print the error message to console and it says "server does
not exist or access denied". I have verified the i have right user id
and password and server is accessible. I have web application
accessing same server and they are working. I am not sure what is the
problem with VB.Net application.

Nov 21 '05 #4
Humble,

That means that there is something with Server or the most likely your
connection string.

Try the most simple ones
http://www.connectionstrings.com/

http://www.carlprothman.net/Default.aspx?tabid=81

I hope this helps,

Cor

"humbleFunGuy" <im**********@hotmail.com> schreef in bericht
news:11**********************@g47g2000cwa.googlegr oups.com...
Cor,
I tried to print the error message to console and it says "server does
not exist or access denied". I have verified the i have right user id
and password and server is accessible. I have web application
accessing same server and they are working. I am not sure what is the
problem with VB.Net application.

Nov 21 '05 #5
humbleFunGuy wrote:
Cor,
I tried to print the error message to console and it says "server does
not exist or access denied". I have verified the i have right user id
and password and server is accessible. I have web application
accessing same server and they are working. I am not sure what is the
problem with VB.Net application.


Try putting the IP in for the Data Source. Also, I've never seen "(..)"
around the data source, but that doesn't mean it's not right... I just
never use it. There is something wrong in your connection string
though, so that's what you got to fix. Make sure you can ping the
server as well.

Chris
Nov 21 '05 #6
On 2005-08-28, humbleFunGuy <im**********@hotmail.com> wrote:
Private Sub writeDatabase(ByVal filePath As String, ByVal action As
String)
Dim cnn As SqlConnection
Dim cmd As SqlCommand
Dim sqlStr As String
Dim connStr As String
connStr = "User ID=user;Password=user;Initial Catalog=file;" _
& "Data Source=(database.server.com)"


That's just "Data Source=database.server.com".

"(local)" is a special keyword recognized by the sql server driver.
Except when connecting to a local db, you don't want parentheses around
the data source.
Nov 21 '05 #7
I used the exact same connection string and created C# project and it
worked fine. I am not sure why VB.Net did not work for me.

Thanks for helping.
Irfan

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3023
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
7
12643
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
2
2670
by: Robert McGregor | last post by:
Hi all, I've got a Front End / Back End database that was working just fine. One day i opened the FE to find that if I tried to open one of the linked tables from the database window, nothing...
19
5405
by: adirat | last post by:
I have read a lot on this subject on newsgroups and other access related websites on data corruption, but since we are still not able to isolate the problem – I am posting this detailed explanation...
15
2524
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
9
3815
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
18
9104
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
6
6598
by: xeqister | last post by:
Greetings, We are having a situation here whereby one of our staff created a very huge 32K buffer pool in a production database and caused the database to go down. When we try to reconnect to the...
12
6230
by: Steve | last post by:
I have a database that raises an error when you try to open it and it doesn't open. Trying to open the database with the OpenDatabase method raises the same error. Trying to import any objects...
4
2713
by: raidvvan | last post by:
Hi there, We have been looking for some time now for a database system that can fit a large distributed computing project, but we haven't been able to find one. I was hoping that someone can...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.