Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Wednesday, March 28, 2012

Kind of Important. Connection String

I am having a problem getting into SQL 2005.
My connection string is as follows:

using System.Data.OleDb;

OleDbConnection conn = new OleDbConnection(@."Provider=SqlOleDb;Data Source=Orange;Initial Catalog=Test;");
//tried with taking out comma after Test as well.

I have tried a lot of different permutations here and I cannot get this to work.Don't post a question about an error without posting the error message.|||Is there a good reason you are using OleDB? SQLClient is optimised for SQL Server.

http://www.connectionstrings.com/sql

Monday, March 19, 2012

Keyword not supported: driver

y am i having keywork not supported? is there anything wrong with my connection string ??

==========web config================

<appSettings>
<add key="db" value="icms" />
<add key="db_user" value="sqladmin" />
<add key="db_server" value="server" />
<add key="db_pwd" value="12345" />
<add key="session_timeout" value="600" />
</appSettings
==========DB.vb==============

Dim myDB As New SqlConnection
Dim myCMD As New SqlCommand
Public Sub New()
Dim db_server = AppSettings("db_server")
Dim db = AppSettings("db")
Dim db_user = AppSettings("db_user")
Dim db_pwd = AppSettings("db_pwd")
Dim DBConnection As String = "DRIVER={SQL Server};" & _
"SERVER=" & db_server & ";" & _
"DATABASE=" & db & ";" & _
"UID=" & db_user & ";" & _
"PWD=" & db_pwd & ";" & _
"OPTION=3;"
myDB.ConnectionString = DBConnection
myCMD.Connection = myDB
End Sub
=============================You're using the native SQL objects so it won't like you trying to tell it to use another driver. Plus I doubt some of the other ODBC style entries you have there are valid either.|||I changed the main differences
which i use System.Data.SQLClient, SQLConnection, SQLCommand, and SQLDataReader (instead of System.Data.Odbc, OdbcConnection, OdbcCommand, and OdbcDataReader)

i changed the entire project.. but it doesnt seems to work...

"You're using the native SQL objects so it won't like you trying to tell it to use another driver. Plus I doubt some of the other ODBC style entries you have there are valid either"

i dont quite get what u mean... can u please kindly elaborate ??
im very new to this sqlserver thingy..

thanks alot!|||The connect string you have there is for ODBC. You are not using ODBC you are using the low down and dirty SQL objects - and so you should if you're talking to MS SQL. However, when you use the SQL objects you need to use a different connection string. E.g. 'Password' instead of 'PWD'. If you look at the help for SQLConnection you'll see what it wants.|||ok i have changed it to sql connection.. now i have this strange error which i totally dont understand.. can someone help me?
thanks alot

==================Error================
An error has occurred.

Please report to us the error message
System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'LIMIT'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at icms.DB.q(String myStr) in C:\icms\DB.vb:line 25

=================DB.vb=====================
Imports System.Configuration.ConfigurationSettings
Imports System.Web.HttpContext
Imports System.Data.sqlclient

Public Class DB

Dim myDB As New sqlconnection
Dim myCMD As New sqlCommand

Public Sub New()

Dim db = AppSettings("db")
Dim db_user = AppSettings("db_user")
Dim db_pwd = AppSettings("db_pwd")
Dim db_datasource = AppSettings("db_datasource")
Dim DBConnection As String = "DATA Source=" & db_datasource & ";" & _
"Initial Catalog=" & db & ";" & _
"User ID=" & db_user & ";" & _
"Password=" & db_pwd & ";"
myDB.ConnectionString = DBConnection
myCMD.Connection = myDB

End Sub

Public Function q(ByVal myStr As String) As SqlDataReader
myCMD.CommandText = myStr
Try
myDB.Open()
q = myCMD.ExecuteReader(Data.CommandBehavior.CloseConnection)
Catch ex As Exception
Err(ex.ToString)
End Try

End Function
Public Sub c(ByVal mySTR As String)

Try
myCMD.Connection.Open()
myCMD.CommandText = mySTR
myCMD.ExecuteNonQuery()
myCMD.Connection.Close()
Catch ex As Exception
Err(ex.ToString)
End Try

End Sub
Private Sub Err(ByVal strError As String)
Current.Response.Write("<h1>An error has occurred.</h1><br>" & vbCrLf)
Current.Response.Write("Please report to us the error message<br>" & vbCrLf)
Current.Response.Write(strError)
Current.Response.Flush()
Current.Response.End()
End Sub
End Class
============Web Config====================

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="db" value="icms" />
<add key="db_user" value="sqladmin" />
<add key="db_pwd" value="12345" />
<add key="db_datasource" value="server" />
<add key="session_timeout" value="600" />
</appSettings
<system.web
<compilation defaultLanguage="vb" debug="true" />
<trace enabled="true"/>
<customErrors mode="RemoteOnly" /
</system.web
</configuration|||What SQL Command are you issuing? Oh and I didn't know you can put a space between "Data Source", learn something new everyday!|||Here is the connection string constructing described:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp

keyword / phrase searching

I have to do an app that will contain a lot of string data that will be
keywords and phrases and I will need a very fast search of that material.
Does SQL Server 2005 have any tools that are geared to this kind of search.
I don't think it has to be as fast as google but probably faster than where
clauses using "like" and "in".
Thanks,
TCheck out the Full Text Search features in BooksOnLine.
--
Andrew J. Kelly SQL MVP
"Tina" <TinaMSeaburn@.nospamexcite.com> wrote in message
news:uaSeL83tHHA.3796@.TK2MSFTNGP02.phx.gbl...
>I have to do an app that will contain a lot of string data that will be
>keywords and phrases and I will need a very fast search of that material.
>Does SQL Server 2005 have any tools that are geared to this kind of search.
>I don't think it has to be as fast as google but probably faster than where
>clauses using "like" and "in".
> Thanks,
> T
>

keyword / phrase searching

I have to do an app that will contain a lot of string data that will be
keywords and phrases and I will need a very fast search of that material.
Does SQL Server 2005 have any tools that are geared to this kind of search.
I don't think it has to be as fast as google but probably faster than where
clauses using "like" and "in".
Thanks,
T
Check out the Full Text Search features in BooksOnLine.
Andrew J. Kelly SQL MVP
"Tina" <TinaMSeaburn@.nospamexcite.com> wrote in message
news:uaSeL83tHHA.3796@.TK2MSFTNGP02.phx.gbl...
>I have to do an app that will contain a lot of string data that will be
>keywords and phrases and I will need a very fast search of that material.
>Does SQL Server 2005 have any tools that are geared to this kind of search.
>I don't think it has to be as fast as google but probably faster than where
>clauses using "like" and "in".
> Thanks,
> T
>

keyword / phrase searching

I have to do an app that will contain a lot of string data that will be
keywords and phrases and I will need a very fast search of that material.
Does SQL Server 2005 have any tools that are geared to this kind of search.
I don't think it has to be as fast as google but probably faster than where
clauses using "like" and "in".
Thanks,
TCheck out the Full Text Search features in BooksOnLine.
Andrew J. Kelly SQL MVP
"Tina" <TinaMSeaburn@.nospamexcite.com> wrote in message
news:uaSeL83tHHA.3796@.TK2MSFTNGP02.phx.gbl...
>I have to do an app that will contain a lot of string data that will be
>keywords and phrases and I will need a very fast search of that material.
>Does SQL Server 2005 have any tools that are geared to this kind of search.
>I don't think it has to be as fast as google but probably faster than where
>clauses using "like" and "in".
> Thanks,
> T
>