Tuesday, October 21, 2014

database connections using c# vbnet with sqldatabase

Posted by Gnani Palepu  |  No comments


 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  

 how to connect database in asp.net using oledbconnection vb.net  
 ----------------------------------------------------------------  
 sub Page_Load  
 dim dbconn  
 dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;  
 data source=" & server.mappath("northwind.mdb"))  
 dbconn.Open()  
 end sub  
 how to connect database in asp.net using sqlconnection in web.config  
 ------------------------------------------------------------------------  
 <connectionStrings>  
  <add name="NorthindConnectionString"   
   connectionString=" Server=MyDataServer;Integrated Security=SSPI;Database=Northwind;"  
   providerName="System.Data.SqlClient" />  
 </connectionStrings>  
 SQL Server Connection Strings for ASP.NET Web Applications using C#.net  
 -----------------------------------------------------------------------  
      using System; using System.Windows.Forms; using System.Data.SqlClient; namespace   
 WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }   
 private void button1_Click(object sender, EventArgs e) { string connetionString = null; SqlConnection   
 cnn ; connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User   
 ID=UserName;Password=Password" cnn = new SqlConnection(connetionString); try { cnn.Open();   
 MessageBox.Show ("Connection Open ! "); cnn.Close(); } catch (Exception ex) { MessageBox.Show("Can not   
 open connection ! "); } } } }  
 How do you connect to a sql server database using C#  
   using System;  
   using System.Data.SqlClient;  
   namespace ConsoleCSharp  
   {  
   /// <summary>  
   /// Summary description for Class1.  
   /// </summary>  
   class DataReader_SQL  
   {  
   /// <summary>  
   /// The main entry point for the application.  
   /// </summary>  
   [STAThread]  
   static void Main(string[] args)  
   {  
   //  
   // TODO: Add code to start application here  
   //  
   try  
   {  
   SqlConnection thisConnection = new SqlConnection(@"Network Library=DBMSSOCN;Data   
 Source=192.168.0.100,1433;database=Northwind;User id=Paladine;Password=;");  
   thisConnection.Open();  
   SqlCommand thisCommand = thisConnection.CreateCommand();  
   thisCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers";  
   SqlDataReader thisReader = thisCommand.ExecuteReader();  
   while (thisReader.Read())  
   {  
   Console.WriteLine("\t{0}\t{1}", thisReader["CustomerID"], thisReader["CompanyName"]);  
   }  
   thisReader.Close();  
   thisConnection.Close();  
   }  
   catch (SqlException e)  
   {  
   Console.WriteLine(e.Message);  
   }  
   }  
   }  
   }  
 How to establish sql database Connection using c#?  
 protected void Button1_Click(Object sender,EventArgs e)  
 {  
 string Text1=TextBox1.Text;  
 string Text2=TextBox2.Text;  
 string connectionString="Data Source=servername;InitialCatalog=DataBaseNameUserID=sa;   
 Password=YourPassword;"  
 SqlConnection sqlConnection=new SqlConnection(connectionString);  
 string insertStatement="INSERT INTO TableName(column1,column2) VALUES Txtb1+","+Txtb2";  
 SqlCommand sqlCommand=new SqlCommand(insertStatement,sqlConnection);  
 try  
 {  
 sqlConnection.Open();  
 sqlCommand.ExecuteNonQuery();  
 }  
 finally  
 {  
 sqlConnection.Close();  
 }  
 }  
 How to connect the SQL database from C#  
 string connectionString = "server=(local)\SQLExpress;database=Northwind;integrated Security=SSPI;";  
 using(SqlConnection _con = new SqlConnection(connectionString))  
 {  
   string queryStatement = "SELECT TOP 5 * FROM dbo.Customers ORDER BY CustomerID";  
   using(SqlCommand _cmd = new SqlCommand(queryStatement, _con))  
   {  
    DataTable customerTable = new DataTable("Top5Customers");  
    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);  
    _con.Open();  
    _dap.Fill(customerTable);  
    _con.Close();  
   }  
 }  
 how to connect database using c# , vb , c++  
 //...........C# .net   
 public void CreateSqlConnection()     
 {     
 SqlConnection myConnection = new SqlConnection();     
 myConnection.ConnectionString = "Persist Security Info=False;Integrated   
 Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";     
 myConnection.Open();     
 }    
 //...........VB.net   
 Public Sub CreateSqlConnection()     
 Dim myConnection As New SqlConnection()     
 myConnection.ConnectionString = "Persist Security Info=False;Integrated   
 Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30"     
 myConnection.Open()     
 End Sub 'CreateSqlConnection     
 //..........C++    
 public:     
 void CreateSqlConnection()     
 {     
 SqlConnection* myConnection = new SqlConnection();     
 myConnection->ConnectionString = S"Persist Security Info=False;Integrated   
 Security=SSPI;database=northwind;server=mySQLServer;Connect Timeout=30";     
 myConnection->Open();     
 }     
 How to connect to Mysql database in web application using asp.net with c#  
 -----------------------------------------------------------------------------  
 //Create MySQLConnection Object  
       MySqlConnection conn = new   
 MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["YourConnectionString"].Con  
 nectionString);  
       //Sample Select Query   
       string strSQL = "SELECT ID, FirstName, LastName FROM YourTable";  
       //Open the Connection  
       conn.Open();  
       //Create MySqlDataAdapter object and assign the query and connection to it  
       MySqlDataAdapter mydata = new MySqlDataAdapter(strSQL, conn);  
       //Create MySqlCommandBuilder object  
       MySqlCommandBuilder cmd = new MySqlCommandBuilder(mydata);  
       //Dataset to hold the values  
       DataSet ds = new DataSet();  
       //Fill the data from MYSQL DB  
       mydata.Fill(ds);  
       YourGridView.DataSource = ds;  
       YourGridView.DataBind();  
       //Close the connection  
       conn.Close();  

 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  


6:57 AM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top